<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Functional Component Example</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
  <functional-button @click="handleClick"></functional-button>
</div>
<script>
  const FunctionalButton = {
    functional: true,
    render(h, context) {
      return h('button', {
        // 合并传递过来的 data 对象
        ...context.data,
        // 使用 context.listeners 设置事件监听器
        on: context.listeners
      }, 'Click Me');
    }
  };
  const vm = new Vue({
    el: '#app',
    components: {
      'functional-button': FunctionalButton
    },
    methods: {
      handleClick() {
        alert('Button clicked!');
      }
    }
  });
</script>
</body>
</html>